package com.ymatou.iapi.img.testcase;

import java.io.File;
import java.io.FileInputStream;

import org.apache.commons.codec.digest.DigestUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.img.api.parameter.UploadImageBean;
import com.ymatou.img.api.service.UploadImageCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 上传图片 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_UploadImage {
	private static UploadImageBean uploadbean;
	private static UploadImageCall uploadcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("上传图片");
	}

	@Before
	public void caseUp() {
		uploadbean = new UploadImageBean();
		uploadcall = new UploadImageCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(uploadcall.getOpurl());
		TestDataManager.removeTempFile();
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UploadImage_001() {
		Logger.start(true, "上传product图片成功,_l_s_b_i图片生成");
		try {
			String type = "product";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_l");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_i");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_002() {
		Logger.start(true, "上传userlogo图片成功,_s_m_b_lb图片生成(默认jpg图片)");
		try {
			String type = "userlogo";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_m");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_lb");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_003() {
		Logger.start(true, "上传catalog图片成功,_t图片生成");
		try {
			String type = "catalog";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_t");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_004() {
		Logger.start(true, "上传shangou图片成功,_l_ls_lb图片生成");
		try {
			String type = "shangou";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_l");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_ls");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_lb");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_005() {
		Logger.start(true, "上传talk图片成功,_c图片生成");
		try {
			String type = "talk";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_c");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_006() {
		Logger.start(true, "上传activity图片成功,_c图片生成");
		try {
			String type = "Activity";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_007() {
		Logger.start(true, "上传ordershow图片成功,_c图片生成");
		try {
			String type = "ordershow";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_c");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	@Ignore
	//规则变更
	public void Tc_UploadImage_008() {
		Logger.start(true, "上传apprecommendbanner图片成功,_s_w_p图片生成");
		try {
			String type = "apprecommendbanner";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_p");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_009() {
		Logger.start(true, "上传gif图片成功");
		try {
			String type = "product";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "upload.gif";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_l");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_i");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_010() {
		Logger.start(true, "上传png图片成功");
		try {
			String type = "product";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "upload.png";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_l");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_i");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_011() {
		Logger.start(true, "上传bmp图片成功");
		try {
			String type = "product";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "upload.bmp";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_l");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_i");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_012() {
		Logger.start(true, "上传分辨率较大图片成功,_c图片生成");
		try {
			String type = "talk";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "upload.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_c");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_013() {
		Logger.start(true, "上传shop图片成功,_s图片生成");
		try {
			String type = "shop";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_thumbnail");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
//	@Ignore 修改此case可以查看性能
	public void Tc_UploadImage_014() {
		Logger.start(true, "重复上传shangou图片成功,MD5验证不会重复生成图片");
		try {
			String type = "product";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			for(int i=0;i<3;i++){
				uploadcall=new UploadImageCall();
				uploadcall.setData(uploadbean);
				Logger.comment("添加上传文件:" + fliename);
				uploadcall.addPart("file", fliename);
				uploadcall.callService();
				if(turl.length()>1) {
					Logger.verifyEquals(turl,uploadcall.getPicUrl(),"MD5验证不会重复生成图片");
				}
				turl=uploadcall.getPicUrl();
			}
			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_015() {
		Logger.start(true, "上传social图片成功,_s图片生成");
		try {
			String type = "social";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_t");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_UploadImage_016() {
		Logger.start(true, "上传userlogo使用png图片成功,生成jpg图片,路径pic1.ymatou.com)JIRACONN-5421");
		try {
			String type = "userlogo";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "upload.png";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			Logger.verifyIsContains("jpg", uploadcall.getPicUrl(), "验证图片地址jpg");
			Logger.verifyIsContains("jpg", uploadcall.getPicUrl(), "验证图片地址pic1.ymatou.com");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_m");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_lb");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UploadImage_017() {
		//isCheckMd5="false" 
		Logger.start(true, "social配置disconf,isCheckMd5=false,不校验md5");
		try {
			String type = "social";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "Penguins.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_t");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			uploadcall.callService();
			String turl2 = changeUrl(uploadcall.getPicUrl(), "_t");
			Logger.debug(turl+":"+turl2);
			Logger.verifyEquals(false,turl.equals(turl2), "不校验md5图片重复生成");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	//http://jira.ymatou.cn:8080/browse/JIRACONN-30921
	//md5不重传 请删除--select * from imagemd5.filemd5 where filemd5.FilePath=
	public void Tc_UploadImage_018() {
		Logger.start(true, "上传product图片成功,JIRACONN-30921修复JPG上传红图问题");
		try {
			String type = "product";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "origin.jpg";
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_l");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_s");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_b");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl = changeUrl(uploadcall.getPicUrl(), "_i");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UploadImage_019() {
		Logger.start(true, "上传share 图片成功,原始图片生成");
		try {
			String type = "share";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "idCard.jpg";
			String fmd5 = DigestUtils.md5Hex(new FileInputStream(fliename));
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_o");
			String dfmd5 = DigestUtils.md5Hex(new FileInputStream(TestDataManager.DownloadFile(turl)));
			Logger.debug(fmd5+":"+dfmd5);
			Logger.verifyEquals(fmd5, dfmd5, "验证md5");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UploadImage_020() {
		Logger.start(true, "上传shenqiProduct 图片成功,自动校正");
		try {
			String type = "shenqiProduct";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "111.jpg";
			String fmd5 = DigestUtils.md5Hex(new FileInputStream(fliename));
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
//			turl = changeUrl(uploadcall.getPicUrl(), "_wk");
//			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
//					+ "是否是图片");
//			String dfmd5 = DigestUtils.md5Hex(new FileInputStream(TestDataManager.DownloadFile(turl)));
//			Logger.debug(fmd5+":"+dfmd5);
//			Logger.verifyEquals(fmd5, dfmd5, "验证md5");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UploadImage_021() {
		Logger.start(true, "上传shenqiProduct 图片成功,自动校正-带水印");
		try {
			String type = "shenqiProduct";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			uploadbean.setWaterMark("test23===aaaa1");
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "111.jpg";
			String fmd5 = DigestUtils.md5Hex(new FileInputStream(fliename));
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl=turl.replace("_w", "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			
			turl = changeUrl(uploadcall.getPicUrl(), "_lb");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			
//			String dfmd5 = DigestUtils.md5Hex(new FileInputStream(TestDataManager.DownloadFile(turl)));
//			Logger.debug(fmd5+":"+dfmd5);
//			Logger.verifyEquals(fmd5, dfmd5, "验证md5");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_UploadImage_022() {
		Logger.start(true, "上传shenqiProduct图片成功,自动校正-带水印-带MchId参数");
		try {
			//oo  lb 没水印
			//wo 有WaterMark 跟着WaterMark 没有看MchId 检查 godmchdb.mch_config 配置是否开启水印 如果MchId和ParentMchId同时存在看ParentMchId
			String type = "shenqiProduct";
			String turl = "";
			Logger.comment("setPicType:" + type);
			uploadbean.setPicType(type);
			uploadbean.setMchId(6002);
			uploadbean.setParentMchId(6000);
//			uploadbean.setWaterMark("虎哥的店PRD");
			String fliename = System.getProperty("user.dir") + File.separator + "resource" + File.separator
					+ "111.jpg";
			String fmd5 = DigestUtils.md5Hex(new FileInputStream(fliename));
			uploadcall.setData(uploadbean);
			Logger.comment("添加上传文件:" + fliename);
			uploadcall.addPart("file", fliename);

			uploadcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, uploadcall.getStatus(), "验证Status");
			Logger.verifyEquals(ECode.PIC_UPLOAD_SUCCESS, uploadcall.getMsg(), "验证Msg");
			Logger.verifyNotNull(uploadcall.getPicUrl(), "验证图片地址非空");
			turl = changeUrl(uploadcall.getPicUrl(), "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			turl=turl.replace("_w", "_o");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
			
			turl = changeUrl(uploadcall.getPicUrl(), "_lb");
			Logger.verifyEquals(true, TestDataManager.isPic(new File(TestDataManager.DownloadFile(turl))), "验证" + turl
					+ "是否是图片");
//			String dfmd5 = DigestUtils.md5Hex(new FileInputStream(TestDataManager.DownloadFile(turl)));
//			Logger.debug(fmd5+":"+dfmd5);
//			Logger.verifyEquals(fmd5, dfmd5, "验证md5");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/**
	 * 修改url地址，本case专用 用于在原来的地址文件名后加后缀
	 * 
	 * @return 修改后的地址
	 */
	private static String changeUrl(String url, String suffix) {
		return url.substring(0, url.lastIndexOf("_")) + suffix + url.substring(url.lastIndexOf("."), url.length());
	}
}